using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace WindowsFormsApplication1.WebTest
{
    class DictionaryPropertyDescriptor : PropertyDescriptor
    {
        private readonly NodeDescriptionPropertiesCollection _collection = new NodeDescriptionPropertiesCollection();
        private readonly string _key;

        public DictionaryPropertyDescriptor(NodeDescriptionPropertiesCollection coll, string key)
            : base("#" + key, null)
        {
            _collection = coll;
            _key = key;
        }

        public override string Category
        {
            get
            {
                return _collection[_key].Category;
            }
        }

        public override bool CanResetValue(object component)
        {
            return true;
        }

        public override Type ComponentType
        {
            get
            {
                return this._collection.GetType();
            }
        }

        public override string DisplayName
        {
            get
            {
                return _collection[_key].Name;
            }
        }

        public override string Description
        {
            get
            {
                return _collection[_key].Description;
            }
        }

        public override object GetValue(object component)
        {
            return _collection[_key].Value;
        }

        public override bool IsReadOnly
        {
            get { return true; }
        }

        public override string Name
        {
            get { return _collection[_key].Name; }
        }

        public override Type PropertyType
        {
            get { return _collection[_key].ParameterType; }
        }

        public override void ResetValue(object component) { }

        public override bool ShouldSerializeValue(object component)
        {
            return true;
        }

        public override void SetValue(object component, object value)
        {

        }

    }
}